WOLF core
WOLF: A Modular Estimation Framework for Robotics
XXXXXXXXXXXXXXXXXXXXXXXXvoid(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
capture_motion.h
Go to the documentation of this file.
1// WOLF - Copyright (C) 2020-2026
2// Institut de Robòtica i Informàtica Industrial, CSIC-UPC.
3// Authors: Joan Solà Ortega (jsola@iri.upc.edu) and
4// Joan Vallvé Navarro (jvallve@iri.upc.edu)
5// All rights reserved.
6//
7// This file is part of WOLF: http://www.iri.upc.edu/wolf
8// WOLF is free software: you can redistribute it and/or modify
9// it under the terms of the GNU General Public License version 3
10// as published by the Free Software Foundation.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once
20
21// Wolf includes
24
25// STL includes
26#include <list>
27#include <algorithm>
28#include <iterator>
29#include <utility>
30
31namespace wolf
32{
34
54{
55 public:
58 CaptureMotion(const std::string& _type,
59 const TimeStamp& _ts,
60 SensorBasePtr _sensor_ptr,
61 const Eigen::VectorXd& _data,
62 CaptureBasePtr _capture_origin_ptr,
63 const TypeComposite& _state_types = {},
64 const VectorComposite& _state_vectors = {},
65 const PriorComposite& _state_priors = {});
66
69 CaptureMotion(const std::string& _type,
70 const TimeStamp& _ts,
71 SensorBasePtr _sensor_ptr,
72 const Eigen::VectorXd& _data,
73 const Eigen::MatrixXd& _data_cov,
74 CaptureBasePtr _capture_origin_ptr,
75 const TypeComposite& _state_types = {},
76 const VectorComposite& _state_vectors = {},
77 const PriorComposite& _state_priors = {});
78
79 ~CaptureMotion() override;
80
81 // Type
82 bool isMotion() const override
83 {
84 return true;
85 }
86
87 // Data
90 const Eigen::VectorXd& getData() const;
91
94 const Eigen::MatrixXd& getDataCovariance() const;
95
98 void setData(const Eigen::VectorXd& _data);
99
102 void setDataCovariance(const Eigen::MatrixXd& _data_cov);
103
104 // Buffer
108
111 const MotionBuffer& getBuffer() const;
112
113 // Buffer's initial conditions for pre-integration
116 Eigen::VectorXd getCalibrationPreint() const;
117
120 void setCalibrationPreint(const Eigen::VectorXd& _calib_preint);
121
125 Eigen::MatrixXd getJacobianCalib() const;
126
130 Eigen::MatrixXd getJacobianCalib(const TimeStamp& _ts) const;
131
132 // Get delta preintegrated, and corrected for changes on calibration params
135 Eigen::VectorXd getDeltaPreint() const;
136
139 Eigen::VectorXd getDeltaPreint(const TimeStamp& _ts) const;
140
143 Eigen::MatrixXd getDeltaPreintCov() const;
144
147 Eigen::MatrixXd getDeltaPreintCov(const TimeStamp& _ts) const;
148
149 // Origin frame and capture
152 CaptureBasePtr getOriginCapture();
153
156 CaptureBaseConstPtr getOriginCapture() const;
157
160 void setOriginCapture(CaptureBasePtr _capture_origin_ptr);
161
165 bool containsTimeStamp(const TimeStamp& _ts, double _time_tolerance) const;
166
171 double distanceToTimeStamp(const TimeStamp& _ts) const;
172
173 void printHeader(int depth, //
174 bool factored_by, //
175 bool metric, //
176 bool state_blocks,
177 std::ostream& stream,
178 std::string _tabs = "") const override;
179
180 // member data:
181 private:
182 Eigen::VectorXd data_;
183 Eigen::MatrixXd data_cov_;
184 Eigen::VectorXd calib_preint_;
185 MotionBuffer buffer_;
186 CaptureBaseWPtr capture_origin_ptr_;
187};
188
189inline const Eigen::VectorXd& CaptureMotion::getData() const
190{
191 return data_;
192}
193
194inline const Eigen::MatrixXd& CaptureMotion::getDataCovariance() const
195{
196 return data_cov_;
197}
198
199inline void CaptureMotion::setData(const Eigen::VectorXd& _data)
200{
201 assert(_data.size() == data_.size() && "Wrong size of data vector!");
202 data_ = _data;
203}
204
205inline void CaptureMotion::setDataCovariance(const Eigen::MatrixXd& _data_cov)
206{
207 assert(_data_cov.rows() == data_cov_.rows() && "Wrong number of rows of data vector!");
208 assert(_data_cov.cols() == data_cov_.cols() && "Wrong number of cols of data vector!");
209 data_cov_ = _data_cov;
210}
211
213{
214 return buffer_;
215}
216
218{
219 return buffer_;
220}
221
222inline Eigen::MatrixXd CaptureMotion::getJacobianCalib() const
223{
224 return getBuffer().back().jacobian_calib_;
225}
226
227inline Eigen::MatrixXd CaptureMotion::getJacobianCalib(const TimeStamp& _ts) const
228{
229 return getBuffer().getMotion(_ts).jacobian_calib_;
230}
231
232inline wolf::CaptureBasePtr CaptureMotion::getOriginCapture()
233{
234 return capture_origin_ptr_.lock();
235}
236
237inline wolf::CaptureBaseConstPtr CaptureMotion::getOriginCapture() const
238{
239 return capture_origin_ptr_.lock();
240}
241
242inline void CaptureMotion::setOriginCapture(CaptureBasePtr _capture_origin_ptr)
243{
244 capture_origin_ptr_ = _capture_origin_ptr;
245}
246
247inline Eigen::VectorXd CaptureMotion::getCalibrationPreint() const
248{
249 return calib_preint_;
250}
251
252inline void CaptureMotion::setCalibrationPreint(const Eigen::VectorXd& _calib_preint)
253{
254 calib_preint_ = _calib_preint;
255}
256
257inline Eigen::VectorXd CaptureMotion::getDeltaPreint() const
258{
259 return getBuffer().back().delta_integr_;
260}
261
262inline Eigen::VectorXd CaptureMotion::getDeltaPreint(const TimeStamp& _ts) const
263{
264 return getBuffer().getMotion(_ts).delta_integr_;
265}
266
267inline Eigen::MatrixXd CaptureMotion::getDeltaPreintCov() const
268{
269 return getBuffer().back().delta_integr_cov_;
270}
271
272inline Eigen::MatrixXd CaptureMotion::getDeltaPreintCov(const TimeStamp& _ts) const
273{
275}
276
277} // namespace wolf
Base class of captures: a sensor measurement taken at a time stamp, linked to a frame,...
Definition: capture_base.h:41
Base class for motion Captures.
Definition: capture_motion.h:54
~CaptureMotion() override
Definition: capture_motion.cpp:59
void printHeader(int depth, bool factored_by, bool metric, bool state_blocks, std::ostream &stream, std::string _tabs="") const override
Prints the information of this node (not of its children)
Definition: capture_motion.cpp:103
const Eigen::VectorXd & getData() const
Returns the motion data.
Definition: capture_motion.h:189
bool isMotion() const override
Returns whether the capture is a motion capture (CaptureMotion)
Definition: capture_motion.h:82
void setData(const Eigen::VectorXd &_data)
Sets the motion data (of the same size)
Definition: capture_motion.h:199
const Eigen::MatrixXd & getDataCovariance() const
Returns the motion data covariance.
Definition: capture_motion.h:194
MotionBuffer & getBuffer()
Returns the buffer of pre-integrated motions.
Definition: capture_motion.h:217
Eigen::VectorXd getDeltaPreint() const
Returns the pre-integrated delta of the last motion of the buffer.
Definition: capture_motion.h:257
void setOriginCapture(CaptureBasePtr _capture_origin_ptr)
Sets the origin capture of the motion.
Definition: capture_motion.h:242
CaptureBasePtr getOriginCapture()
Returns the origin capture of the motion.
Definition: capture_motion.h:232
double distanceToTimeStamp(const TimeStamp &_ts) const
Distance from a time stamp to the time interval covered by this capture.
Definition: capture_motion.cpp:89
void setCalibrationPreint(const Eigen::VectorXd &_calib_preint)
Sets the calibration parameters used during pre-integration.
Definition: capture_motion.h:252
Eigen::MatrixXd getDeltaPreintCov() const
Returns the pre-integrated delta covariance of the last motion of the buffer.
Definition: capture_motion.h:267
Eigen::MatrixXd getJacobianCalib() const
Returns the Jacobian of the pre-integrated delta wrt the calibration parameters, of the last motion o...
Definition: capture_motion.h:222
bool containsTimeStamp(const TimeStamp &_ts, double _time_tolerance) const
Returns whether _ts is within the time span of the buffer (or close to the capture time stamp if the ...
Definition: capture_motion.cpp:64
void setDataCovariance(const Eigen::MatrixXd &_data_cov)
Sets the motion data covariance (of the same size)
Definition: capture_motion.h:205
CaptureMotion(const std::string &_type, const TimeStamp &_ts, SensorBasePtr _sensor_ptr, const Eigen::VectorXd &_data, CaptureBasePtr _capture_origin_ptr, const TypeComposite &_state_types={}, const VectorComposite &_state_vectors={}, const PriorComposite &_state_priors={})
Constructor without data covariance: it is computed by the sensor (zero if no sensor)
Definition: capture_motion.cpp:23
Eigen::VectorXd getCalibrationPreint() const
Returns the calibration parameters used during pre-integration.
Definition: capture_motion.h:247
Buffer of motions (pre-integrated deltas) of a CaptureMotion.
Definition: motion_buffer.h:108
const Motion & getMotion(const TimeStamp &_ts) const
Returns the motion at _ts, following the rules of the class description.
Definition: motion_buffer.cpp:85
TimeStamp implements basic functionalities for time stamps.
Definition: time_stamp.h:39
Composite of state vectors.
Definition: vector_composite.h:29
Definition: capture_base.h:23
WOLF_PTR_TYPEDEFS(CaptureLandmarksExternal)
Eigen::VectorXd delta_integr_
The integrated motion or delta-integral.
Definition: motion_buffer.h:44
Eigen::MatrixXd jacobian_calib_
Jacobian of delta_integr wrt extra states (TBD by the derived processors)
Definition: motion_buffer.h:48
Eigen::MatrixXd delta_integr_cov_
Covariance of the integrated delta.
Definition: motion_buffer.h:45